﻿using RuoVea.ExSugar;

namespace Gantt.Web.Controllers
{

    /// <summary>
    /// 
    /// </summary>
    [Authorize(Roles = "None")]
    public partial class GanttController : Controller
    {
        private readonly GanttService _ganttService;

        public GanttController(GanttService ganttService)
        {
            _ganttService = ganttService;
        }

        public IActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 查询所有/分页
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost("gantt/pages")]
        public async Task<RestfulResult<List<TasksModel>>> GetPagesAsync([FromBody] TasksPageParam data)
        {
            return await _ganttService.GetPagesAsync(data);
        }

        /// <summary>
        /// 查询所有-任务列表
        /// </summary>
        /// <returns></returns>
        [HttpGet("gantt/tasks/{id}")]
        public async Task<RestfulResult<List<ProjectDto>>> GetTasksListAsync(long id)
        {
            return await _ganttService.GetTasksListAsync(id);
        }

 /// <summary>
        /// 查询所有-甘特图类型
        /// </summary>
        /// <returns></returns>
        [HttpPost("gantt/type")]
        public async Task<RestfulResult<PageResult<ProjectDto>>> GetTypeListAsync()
        {
            return await _ganttService.GetTypeListAsync();
        }

        /// <summary>
        /// 查询所有-甘特图状态
        /// </summary>
        /// <returns></returns>
        [HttpPost("gantt/status")]
        public async Task<RestfulResult<PageResult<StatusDto>>> GetStatusListAsync()
        {
            return await _ganttService.GetStatusListAsync();
        }

        /// <summary>
        [HttpPost("gantt/level")]
        public async Task<RestfulResult<PageResult<StatusDto>>> GetLevelListAsync()
        {
            return await _ganttService.GetLevelListAsync();
        }

        /// 修改
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost("gantt/submit")]
        public async Task<RestfulResult> SubmitAsync([FromBody] TasksInputDto data)
        {
            return await _ganttService.SubmitAsync(data);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete("gantt/delete/{id:long}")]
        public async Task<RestfulResult> DeleteAsync(long id)
        {
            return await _ganttService.DeleteAsync(id);
        }
    }
}